Go here or to previous homework to remind yourself how to get set up.
Once your repository is created, you should always open your project rather than just opening an .Rmd file. You can do that by either clicking on the .Rproj file in your repository folder on your computer. Or, by going to the upper right hand corner in R Studio and clicking the arrow next to where it says Project: (None). You should see your project come up in that list if you’ve used it recently. You could also go to File –> Open Project and navigate to your .Rproj file.
Put your name at the top of the document.
For ALL graphs, you should include appropriate labels.
Feel free to change the default theme, which I currently have set to theme_minimal().
Use good coding practice. Read the short sections on good code with pipes and ggplot2. This is part of your grade!
NEW!! With animated graphs, add eval=FALSE to the code chunk that creates the animation and saves it using anim_save(). Add another code chunk to reread the gif back into the file. See the tutorial for help.
When you are finished with ALL the exercises, uncomment the options at the top so your document looks nicer. Don’t do it before then, or else you might miss some important warnings and messages.
ggplotly() function.small_trains dataset that contains data from the SNCF (National Society of French Railways). These are Tidy Tuesday data! Read more about it here.geom_area() examples here). You will look at cumulative harvest of tomato varieties over time. You should do the following:garden_harvest data, filter the data to the tomatoes and find the daily harvest in pounds for each variety.fct_reorder()) from most to least harvested (most on the bottom).I have started the code for you below. The complete() function creates a row for all unique date/variety combinations. If a variety is not harvested on one of the harvest dates in the dataset, it is filled with a value of 0.
mallorca_bike_day7 bike ride using animation! Requirements:ggmap.ggimage package and geom_image to add a bike image instead of a red point. You can use this image. See here for an example.I think if I were going to be studying the data/map for a long period of time I’d definitely choose the static map, as staring at the gif can be slightly annoying after a long time, but in general, just to visualize the data, I prefer the animation. Especially as this is showing a journey, the animation adds more to our understanding versus just seeing the path already laid out.
panama_swim, panama_bike, and panama_run. Create a similar map to the one you created with my cycling data. You will need to make some small changes: 1. combine the files (HINT: bind_rows(), 2. make the leading dot a different color depending on the event (for an extra challenge, make it a different image using `geom_image()!), 3. CHALLENGE (optional): color by speed, which you will need to compute on your own from the data. You can read Heather’s race report here. She is also in the Macalester Athletics Hall of Fame and still has records at the pool.lag() function you’ve used in a previous set of exercises). Replace missing values with 0’s using replace_na().geom_path() and add a group aesthetic. Put the x and y axis on the log scale and make the tick labels look nice - scales::comma is one option. This plot will look pretty ugly as is.geom_point()) and add the state name as a label (geom_text() - you should look at the check_overlap argument).animate() function to have 200 frames in your animation and make it 30 seconds long.I’m having a really weird error - the graph was animating totally fine until I went to do the final anim save and put it into a gif when it started saying that ‘weekly_cases_by_state’ doesn’t exist. If I highlight the code and run it up to that point it works, and it saves the code chunk to ‘weekly_cases_by_state’, until I try to animate and then it says that file does not exist. I renamed it, reloaded my libraries and data a few types, renamed the file, and tried to find solutions online but I didn’t see any that quite matched my issue.
But from what I saw before the error, it was interesting to now be able to see the trends over time, considering it doesn’t seem like that long ago that New York was just starting to shoot up, but we now have months of data past that. I’m interested now in looking at what precautions were put into place in Guam, considering how quickly they dropped down in new cases (it may have a lot to do with being an island with a small population, but there’s probably still other factors).
wday() to create a day of week variable and filter to all the Fridays.I’m also encountering an error I can’t figure out in this problem, this time to do with ‘transition_reveal,’ which returns “Error in sprintf(paste0(”%0“, nc,”i“), frame) : invalid format ‘%04i’; use format %f, %e, %g or %a for numeric objects.” I’ve spent awhile trying to figure it out (which I bet means it’s a simple fix that I’m missing) but I think I may just have to leave it here, sorry to do this again but I will definitely go back over it with the solutions!
Even though I can’t see it, I think this map would give similar information to the graph of number 6, but would probably be more readable in terms of looking at both individual states and the country as a whole. It would also show interesting geographical patterns, as you could easily see the trends of neighboring states/regions.
shiny appapp.R file you create. Below, you will post a link to the app that you publish on shinyapps.io. You will create an app to compare states’ cumulative number of COVID cases over time. The x-axis will be number of days since 20+ cases and the y-axis will be cumulative cases on the log scale (scale_y_log10()). We use number of days since 20+ cases on the x-axis so we can make better comparisons of the curve trajectories. You will have an input box where the user can choose which states to compare (selectInput()) and have a submit button to click once the user has chosen all states they’re interested in comparing. The graph should display a different line for each state, with labels either on the graph or in a legend. Color can be used if needed.[05_exercise_Tuggle.md] (https://github.com/mktuggle/Tuggle_exercises_05/blob/main/05_exercises_Tuggle.md)
DID YOU REMEMBER TO UNCOMMENT THE OPTIONS AT THE TOP?